﻿package mortal.game.view.common
{
    import com.gengine.keyBoard.*;
    import com.gengine.manager.*;
    import com.gengine.resource.*;
    import com.gengine.resource.info.*;
    import com.gengine.utils.*;
    import extend.language.*;
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.font.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.mvc.core.*;

    public class KillUserView extends View
    {
        private var _avatar:Bitmap;
        private var _bg:Bitmap;
        private var _line:Bitmap;
        private var _tipTxt:TextField;
        private var _contentTxt:TextField;
        private var _reLoginTxt:TextField;

        public function KillUserView()
        {
            this.init();
            return;
        }// end function

        private function init() : void
        {
            this._avatar = new Bitmap();
            this.addChild(this._avatar);
            UIFactory.bg(110, 45, 329, 150, this, ImagesConst.KillUserBg);
            UIFactory.bg(115, 160, 320, 2, this, ImagesConst.KillUserLine);
            this._tipTxt = UIFactory.textField("", 140, 50, 290, 135, this);
            this._tipTxt.autoSize = TextFieldAutoSize.LEFT;
            this._tipTxt.multiline = true;
            this._tipTxt.htmlText = "<textFormat leading=\'5\'>" + HTMLUtil.addColor(Language.getString(10008), "#ffffff") + "</textFormat>";
            this._contentTxt = UIFactory.textField("", 140, 105, 290, 135, this, new GTextFormat(FontUtil.songtiName, 12, 16777215));
            this._contentTxt.multiline = true;
            this._reLoginTxt = UIFactory.textField("", 315, 170, 220, 30, this, new GTextFormat(FontUtil.songtiName, 16, 6350622));
            this._reLoginTxt.htmlText = "<a href=\'event:1\'>" + Language.getString(10009) + "</a>";
            this._reLoginTxt.addEventListener(TextEvent.LINK, this.onReloadClickHandler);
            LoaderManager.instance.load("zhiyin.png", this.onAvatarLoaded);
            return;
        }// end function

        private function getErrorStrByType(param1:int) : String
        {
            var _loc_3:Object = null;
            var _loc_2:* = Language.getArray(10007);
            var _loc_4:int = 0;
            while (_loc_4 < _loc_2.length)
            {
                
                _loc_3 = _loc_2[_loc_4];
                if (_loc_3.name == param1.toString())
                {
                    return _loc_3.label;
                }
                _loc_4++;
            }
            return "";
        }// end function

        public function updateContentByType(param1:int) : void
        {
            var _loc_2:* = this.getErrorStrByType(param1);
            var _loc_3:* = Language.getString(10006);
            this._contentTxt.htmlText = "<textFormat leading=\'5\'>" + HTMLUtil.addColor(_loc_2, "#f0ea3f") + _loc_3 + "</textFormat>";
            return;
        }// end function

        private function onAvatarLoaded(param1:ImageInfo) : void
        {
            this._avatar.bitmapData = param1.bitmapData;
            return;
        }// end function

        override public function hide() : void
        {
            LayerManager.highestLayer.removePopup(this);
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            LayerManager.highestLayer.addPopUp(this, true);
            LayerManager.highestLayer.centerPopup(this);
            EffectManager.addUIMask([], 0);
            KeyBoardManager.instance.cancelListener();
            return;
        }// end function

        private function onReloadClickHandler(event:TextEvent) : void
        {
            BrowerManager.instance.reload();
            return;
        }// end function

    }
}
